/*****************************************************************
 * Copyright (C) Gasgoo Corporation. All rights reserved.
 * 
 * Author:   Jack Jiang
 * Create Date:  08/26/2006
 * Usage:
 *
 * RevisionHistory
 * Date         Author               Description
 * 
*****************************************************************/
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace ZJFramework.DataAccess
{
	public class CustomDataCommand : DataCommand
	{
		internal CustomDataCommand(NeweggDatabase database)
			: base(database.ToString(), DbCommandFactory.CreateDbCommand())
		{
		}

		internal CustomDataCommand(NeweggDatabase database, CommandType commandType)
			: this(database) 
		{
			CommandType = commandType;
		}

		internal CustomDataCommand(NeweggDatabase database, CommandType commandType, string commandText)
			: this(database, commandType)
		{
			CommandText = commandText;
		}

		public CommandType CommandType
		{
			get { return m_DbCommand.CommandType; }
			set { m_DbCommand.CommandType = value; }
		}

		#region add parameter
		public void AddInputParameter(string name, DbType dbType, Object value)
		{
			ActualDatabase.AddInParameter(m_DbCommand, name, dbType, value);
		}

		public void AddInputParameter(string name, DbType dbType)
		{
			ActualDatabase.AddInParameter(m_DbCommand, name, dbType);
		}
		#endregion


		public string CommandText
		{
			get { return m_DbCommand.CommandText; }
			set { m_DbCommand.CommandText = value; }
		}

		public int CommandTimeout
		{
			get { return m_DbCommand.CommandTimeout; }
			set { m_DbCommand.CommandTimeout = value; }
		}

		public NeweggDatabase Database
		{
			get { return (NeweggDatabase) Enum.Parse(typeof(NeweggDatabase), m_DatabaseName); }
			set { m_DatabaseName = value.ToString(); }
		}
	}
}
